package com.ews.onlineexchange.service.schedule;
import javax.annotation.Resource;
import javax.ejb.Schedule;
import javax.ejb.ScheduleExpression;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.ejb.TimerConfig;
import javax.ejb.TimerService;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import com.ews.onlineexchange.service.BlackListService;
import com.ews.onlineexchange.service.SmsService;

@Singleton
@Startup
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class SmsSenderTimer {

	@Resource
	TimerService timerService;

	@Inject
	EntityManager entityManager;
	@Inject
	BlackListService blackListService;
	@Inject
	SmsService smsService;
//	@PostConstruct
	public void init() {
		ScheduleExpression schedule = new ScheduleExpression();
//		schedule.dayOfWeek("*");
		schedule.hour("*/2");
		timerService.createCalendarTimer(schedule, new TimerConfig("smsSenderTimer", false));

		// check();
	}
	
	@Schedule(hour="9", minute="0", second="0", info = "smsSenderTimer", persistent = false)
	public void check() {		
//		smsService.sendFailedSms();
	}
}
